#!/usr/bin/env sh
#
# Copyright (c) 2018 Iago Sousa <iagosousa@me.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

if [[ -f $1 ]]; then
	case "$1" in
	  *.tar.bz2) tar xvjf "$1";;
	  *.tar.gz) tar xvzf "$1";;
	  *.tar.xz) tar xvf "$1";;
	  *.tar) tar xvf "$1";;
	  *.tgz) tar xvf "$1";;
	  *.xz) tar xvf "$1";;
	  *.gz) gunzip "$1";;
	  *.zip) unzip "$1";;
	  *.rar) unrar x "$1";;
	  *.tbz2) tar xvjf "$1" ;;
	  *.lzma) unlzma "$1" ;;
	  *.Z) uncompress "$1" ;;
	  *.7z) 7z x "$1" ;;
	  *.deb) ar x ./"$1" ;;
	  *) echo "'$1' cannot be extracted via extract."
	esac
else
	echo "'$1' is not a valid file"
fi

# vim: ft=sh
